<template>
  <div>
    <div v-for="(e,i) in list" :key="i">
      <div class="title">
        {{e.groupName}}
        <!-- <el-checkbox
          :indeterminate="e.isIndeterminate"
          v-model="e.isIndeterminat"
          @change="handleCheckAllChange(e)"
        >全选</el-checkbox>-->
        <span 
        class="All"
          @click="handleCheckAllChange(e,e.isIndeterminate=!e.isIndeterminate)"
        >{{e.isIndeterminate?'取消全选':'全选'}}</span>
      </div>
      <div class="boxContent">
        <el-checkbox-group v-model="e.checkedCities">
          <div class="content" v-for="(item,index) in e.children" :key="index">
            <span style="font-size:18px;">{{index+1}}</span>
            <el-checkbox
              :label="item.id"
              @change="handleCheckedCitiesChange(e.checkedCities,item.id,e,item)"
            >{{item.name}}</el-checkbox>
            <!-- <i class=""></i> -->
            <img
              src="../../../assets/image/SoundColumn/volume.png"
              @click="volume(item)"
              width="18"
              alt
            />
            <!-- <div class="modulation" v-show="item.show">
              <el-slider v-model="item.value" vertical height="100px"></el-slider>
            </div>-->
          </div>
        </el-checkbox-group>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    list: {
      type: Array,
      default: []
    }
  },
  watch: {
    list: {
      handler(newVal) {
        var arr = [];
        newVal.forEach(item => {
          arr.push(item.checkedCities);
        });
        this.$emit("Check", arr);
      },
      deep: true
    }
  },
  data() {
    return {
      checkAll: false,
      checkedCities: [],
      checkList: [],
      value: 50,
      show: false
    };
  },
  methods: {
    handleCheckAllChange(value, e) {
     
      value.children.forEach(item => {
        value.checkedCities.push(item.id);
      });
      // var arr=[]
      if (!e) {
        value.checkedCities = [];
      }
    },

    handleCheckedCitiesChange(value, id, e, item) {
      value.push(id);
      if (value.includes(id)) {
        value.forEach((item, index) => {
          if (item == id) {
            value.splice(index, 1);
          }
        });
      }
      value.forEach(item => {
        if (value.length == e.children.length) {
          e.isIndeterminate = true;
        } else {
          e.isIndeterminate = false;
        }
      });
    },
    volume(item) {
      item.show = !item.show;
    }
  }
};
</script>
<style scoped>
.title {
  background-color: #00968e;
  padding: 15px;
  position: relative;
}
.title > .el-checkbox {
  position: absolute;
  right: 40px;
}
.boxContent {
  padding: 15px;
}
.content {
  position: relative;
  display: inline-block;
  padding: 5px;
  width: 175px;
  height: 159px;
  border: 1px solid #ffffff;
  border-radius: 12px;
  margin: 10px;
}
.boxContent .el-checkbox {
  position: absolute;
  left: 30px;
  top: 20px;
}
.boxContent img {
  position: absolute;
  bottom: 10px;
  right: 10px;
}
.modulation {
  position: absolute;
  right: 4px;
  bottom: 40px;
}
/deep/ .el-slider.is-vertical .el-slider__bar,
/deep/ .el-slider.is-vertical .el-slider__runway {
  width: 3px;
}
/deep/ .el-slider__button {
  width: 2;
  height: 2;
  border: 2px solid rgb(9, 218, 186);
  margin-right: 2px;
}
/deep/ .hover {
  /* display: none; */
  border-radius: 50%;
}
/deep/ .el-slider__bar {
  background: rgb(9, 218, 186);
}
  
.All {
  /* position: absolute; */
  float: right;
  margin-right: 100px;
  cursor: pointer;
  border: 1px solid #fff;
  padding: 5px 15px;
   margin-top: -6px;

}
.All:active{
  border: 1px solid rgb(9, 218, 186);
  color: #cccccc;
}
/* .rigth /deep/  .el-slider__button {
    width: 0;
    height:0;
    border:none;
}
.rigth /deep/ .hover  {
    display: none;
} */
</style>